home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Source Code
/
Visual Basic Source Code.iso
/
vbsource
/
callin1g
/
frmdispl.frm
(
.txt
)
< prev
next >
Wrap
Visual Basic Form
|
1999-08-17
|
18KB
|
412 lines
VERSION 5.00
Begin VB.Form frmDisplay
AutoRedraw = -1 'True
BackColor = &H00000000&
BorderStyle = 3 'Fixed Dialog
ClientHeight = 8595
ClientLeft = 150
ClientTop = 1050
ClientWidth = 10365
ControlBox = 0 'False
Icon = "frmDisplay.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
MouseIcon = "frmDisplay.frx":08CA
MousePointer = 99 'Custom
ScaleHeight = 8595
ScaleWidth = 10365
ShowInTaskbar = 0 'False
WindowState = 2 'Maximized
Begin VB.PictureBox picBack
AutoRedraw = -1 'True
AutoSize = -1 'True
BackColor = &H00000000&
Height = 23595
Left = -26400
ScaleHeight = 23535
ScaleWidth = 27420
TabIndex = 2
Top = -22680
Visible = 0 'False
Width = 27480
End
Begin VB.PictureBox picBuf
AutoRedraw = -1 'True
AutoSize = -1 'True
BackColor = &H00000000&
BorderStyle = 0 'None
Height = 6735
Left = -7440
ScaleHeight = 6735
ScaleWidth = 8850
TabIndex = 1
Top = -5520
Width = 8850
End
Begin VB.Timer tmrMove
Enabled = 0 'False
Interval = 50
Left = 1680
Top = 7440
End
Begin VB.PictureBox picSpr
AutoRedraw = -1 'True
AutoSize = -1 'True
Height = 6195
Left = -4440
Picture = "frmDisplay.frx":0A1C
ScaleHeight = 6135
ScaleWidth = 6135
TabIndex = 0
Top = -4680
Visible = 0 'False
Width = 6195
End
Attribute VB_Name = "frmDisplay"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
'========================================================='
'========================================================='
'=============== RPG Game Version 0.0.2 =================='
'============== Written by Matthew Eagar ================='
'============ Compiled in Visual Basic 6.0 ==============='
'========================================================='
'========================================================='
' This program is an example of an RPG game engine made
' with VB 6.0. I drew all the graphics in MS Paint,
' and all coding is origional.
' This isn't ment to be a full game, just a working engine.
' there is no actual objective. I havn't yet got doors
' working, because that would require me to draw some more
' textures for the insides of houses, which takes FOREVER!
' Also, the textures could REALLY use some work,
' as they were drawn in MS Paint.
' This program may not run well on some computers.
' The method used, bitblt, works well, but isn't designed for games.
' It runs fine on a Pentium 233, but slow on a P75. I havn't tested
' it on anything in between those.
' I'm still working on this, so look for me to post newer versions
' of it. It'll remain free, and it's really ment for educational purposes.
' Please contact me with ANY questions, comments, suggestions, or problems,
' ANY input is welcome:
' email: meagar@home.com
' ICQ: 45058462
' Also, I havn't tested this on any computer running anything less then VB6.
' I did run it in vb5, but it took some work.
' You will need the VB6 runtime files the use this.
' Updates to Version 2:
' Added side scrolling and top scrolling
' Rechanged the map size from 13x11 to 30x30 tiles to accomidate side scrolling
' Added Bridge Tiles for bridge construction
' Added sound effects
' re-wrote most of movement code
Dim animX As Integer 'holds the current x location of the animation frame
Dim animY As Integer 'holds the current y location of the animation frame
Dim direction As Integer 'the direction the characters facing
Dim charX As Integer 'holds the character's x coords
Dim charY As Integer 'holds the character's y coords
Dim lastX As Integer 'holds the character's last y coords
Dim lastY As Integer 'holds the character's last x coords
Dim BackBuilt As Integer 'determines if the back ground needs to be built
Dim Speed As Integer 'holds the current speed, set by pressing the + or - keys
Dim mapx As Integer 'holds the current map x number
Dim mapy As Integer 'holds the current map y number
Dim MapName As String 'holds the name of the map
Dim screenX As Integer 'holds the current location of the screen on the map
Dim screenY As Integer 'holds the current location of the screen on the map
Dim charPosX As Integer 'holds the coords to center the character on the screen
Dim charPosY As Integer 'holds the coords to center the character on the screen
Dim sound As Boolean 'holds whether to play sounds or not
'symbolic constants
'directions
Const dLEFT As Integer = 1 'left direction
Const dUP As Integer = 2 'up direction
Const dRIGHT As Integer = 3 'right direction
Const dDOWN As Integer = 4 'down direction
'animation frames
Const aLEFT As Integer = 2 'left animation
Const aUP As Integer = 104 'up animation
Const aRIGHT As Integer = 206 'right animation
Const aDOWN As Integer = 308 'down animation
'when the user presses a key
Private Sub picBuf_KeyDown(KeyCode As Integer, Shift As Integer)
Dim X As Integer 'counting variable
'if movement, turn the mouse cursor into the invisible icon.
'simply making a mouse cursor that was invisible is easier
'then using API calls.
frmDisplay.MouseIcon = frmTextures.picInvisible.Picture
'copy the current location of the character into the lastx and lasty variables.
lastX = screenX
lastY = screenY
'determine how to act, based on which key the user presses.
Select Case KeyCode
Case Is = 37 'left arrow key
animX = aLEFT 'set the animation frame to the proper direction
direction = dLEFT 'set the direction
Case Is = 38 'up arrow key
animX = aUP 'set the animation frame to the proper direction
direction = dUP
Case Is = 39 'right arrow key
animX = aRIGHT
direction = dRIGHT
Case Is = 40 'down arrow key
animX = aDOWN
direction = dDOWN
Case Is = 27 'escape key
'ask if the user would like to exit
If MsgBox("Are you sure you would like to exit?", vbYesNo + vbDefaultButton2 + vbQuestion, "Exit?") = vbYes Then End
Case Is = 109 'minus key - increases screen size
Speed = Speed - 2
If Speed < 5 Then Speed = 5
Case Is = 107 'plus key - decreases screen size
Speed = Speed + 2
If Speed > 20 Then Speed = 20
Case Is = 83 'the S key
'turn sound on or off
If sound = True Then
sound = False
Else
sound = True
End If
End Select
'see if the movement timer should be enabled
If KeyCode >= 37 And KeyCode <= 40 Then 'if a direction key's been pressed
tmrMove.Enabled = True
End If
End Sub
Private Sub picBuf_KeyUp(KeyCode As Integer, Shift As Integer)
'disable the movement timer
tmrMove.Enabled = False
End Sub
Private Sub Form_Load()
'initialize the variables
animX = 2
animY = 1
screenX = 10
screenY = 10
charX = screenX + charPosX + 25
charY = screenY + charPosY + 25
sound = True
BackBuilt = False
'maps are loaded in the following way:
'take the mapX, then add the letter 'a' then take the mapY, then add ".map"
'so, the first map is called 0a0.map, the map beside it is called
'1a0.map, and the map above the first is called 0a1.map
'eventually the middle letter will stand for the area, eg a = lev 1, b = lev 2
mapx = 0 'the current map
mapy = 0
Speed = 15 'set the initial walking speed
'set the size of the main picture box
'change the number to make the picture bigger or smaller, but the number can't be
'large then 1 or smaller then 0
picBuf.Height = Int(Screen.Height * 0.8)
picBuf.Wi